/**
 * Created by shc@lierda.com on 2016/6/27.
 */
var Block = require('./block');
var Login = require('./login');
var Comment = require('./comment');
var Cashier = require('./cashier');
var Pose = require('./pose');
var Dingwei = require('./dingwei');
var Login = require('./login');
var Product = require('./product');
var Cart = require('./cart');
var Order = require('./order');
var Shop = require('./shop');

exports.action=function(app) {
    app.get('/', index);
    app.get('/shopInfo', shopInfo);
    app.post('/action',doAction);
};

function index(req,res){
    res.render("index");
}
function shopInfo(req,res){
    res.render("shopInfo");
}

function doAction(req,res){
    res.header("Access-Control-Allow-Origin", "*");
    var postName = req.body.pn;
    console.log("postName:"+postName);
    var msg = {success:false,msg:"",data:[],totals:0};
    try{
        eval(postName+"(req,res,msg)");
    }catch(e){
        msg.success=false;
        msg.msg="Service does not exist";
        res.json(msg);
    }
}


/**业务action注册*/
//function getPadListByUserid(req,res,msg){ Pad.getPadListByUserid(req,res,msg);}

/**获取首页Banner*/
function getBanner(req,res,msg){ Block.getBanner(req,res,msg);}

/**获取首页功能列表*/
function getFunction(req,res,msg){ Block.getFunction(req,res,msg);}

/**获取对应功能的产品*/
function getGoodsList(req,res,msg){ Shop.getGoodsList(req,res,msg);}

/**获取首页商品*/
function getHomePagePro(req,res,msg){ Shop.getHomePagePro(req,res,msg);}

/**获取喜好商品*/
function getLoveGoods(req,res,msg){ Shop.getLoveGoods(req,res,msg);}

////////
////////
////////
////////
////////
////////
/**获取商品的分类信息*/
function getProductCate(req,res,msg){ Product.getProductCate(req,res,msg);}

/**根据分类的id获取分类下的商品信息*/
function getCateproinfo(req,res,msg){ Product.getCateproinfo(req,res,msg);}

/**根据分类的id获取分类下的商品信息*/
function getProinfoByid(req,res,msg){ Product.getProinfoByid(req,res,msg);}

/**根据商品id获取商品信息*/
function getGoodsDetailByid(req,res,msg){ Product.getGoodsDetailByid(req,res,msg);}

/**根据cate_id获取商品信息*/
function getGoodsInfoByCateid(req,res,msg){ Product.getGoodsInfoByCateid(req,res,msg);}

/**根据搜索关键字获取商品信息*/
function getSearchPro(req,res,msg){ Product.getSearchPro(req,res,msg);}

/**购物车添加商品信息*/
function addCart(req,res,msg){ Cart.addCart(req,res,msg);}

/**根据用户id获取购物车列表信息*/
function getCartlistByid(req,res,msg){ Cart.getCartlistByid(req,res,msg);}

/**根据user_id获取购物车店铺列表*/
function getCartShopid(req,res,msg){ Cart.getCartShopid(req,res,msg);}

/**根据shop_id获取用户的购物车列表*/
function getCartByShopid(req,res,msg){ Cart.getCartByShopid(req,res,msg);}

/**根据用户id获取购物车列表信息*/
function getCartlistByGoodsId(req,res,msg){ Cart.getCartlistByGoodsId(req,res,msg);}

/**根据用户id获取购物车列表信息*/
function updateCart(req,res,msg){ Cart.updateCart(req,res,msg);}

/**根据用户和商品ID删除添加到订单的商品*/
function deleteCartProByGoodsId(req,res,msg){ Cart.deleteCartProByGoodsId(req,res,msg);}

/**根据商品ID删除购物车商品*/
function deleteCartByGoodid(req,res,msg){ Cart.deleteCartByGoodid(req,res,msg);}

/**更新数量*/
function updateGoodsnum(req,res,msg){ Cart.updateGoodsnum(req,res,msg);}

/**下订单减少库存*/
function updateKucun(req,res,msg){ Cart.updateKucun(req,res,msg);}

/**结算时添加商品信息到商品订单表中*/
function addOrderGoods(req,res,msg){ Order.addOrderGoods(req,res,msg);}

/**结算时添加订单信息到订单表中*/
function addOrderInfo(req,res,msg){ Order.addOrderInfo(req,res,msg);}

/**判断订单是否免邮*/
function getShipping(req,res,msg){ Order.getShipping(req,res,msg);}

/**获取订单折扣商品信息*/
function getZhezhouPro(req,res,msg){ Order.getZhezhouPro(req,res,msg);}

/**根据userid查询订单信息*/
function getOrderByUserId(req,res,msg){ Order.getOrderByUserId(req,res,msg);}

/**根据orderId获取订单商品信息*/
function getOrderGoods(req,res,msg){ Order.getOrderGoods(req,res,msg);}

/**更新订单收货地址*/
function UpdateAddressToOrderInfo(req,res,msg){ Order.UpdateAddressToOrderInfo(req,res,msg);}

/**更新订单支付信息*/
function UpdatePay(req,res,msg){ Order.UpdatePay(req,res,msg);}

/**确认收货*/
function updateShippingStatus(req,res,msg){ Order.updateShippingStatus(req,res,msg);}

/**通过订单ID获取物流信息*/
function getLogisticsByOrderid(req,res,msg){ Order.getLogisticsByOrderid(req,res,msg);}

/**取消订单*/
function deleteOrderInfo(req,res,msg){ Order.deleteOrderInfo(req,res,msg);}

/**获取店铺信息*/
function getShopById(req,res,msg){ Shop.getShopById(req,res,msg);}

/**首页的获取店铺产品信息*/
function getShopProinfo(req,res,msg){ Shop.getShopProinfo(req,res,msg);}


function getSearch(req,res,msg){ Shop.getSearch(req,res,msg);}

/**店铺分类名称*/
function getCatagoryName(req,res,msg){ Shop.getCatagoryName(req,res,msg);}

/**首页的获取新品发布的产品信息*/
function getIsNewProinfo(req,res,msg){ Shop.getIsNewProinfo(req,res,msg);}

/**根据商品id获取商品详情*/
function getProinfoById(req,res,msg){Shop.getProinfoById(req,res,msg);}

/**根据商品id获取new商品详情*/
function getNewGoodsDetailByid(req,res,msg){ Product.getNewGoodsDetailByid(req,res,msg);}

/**更新限时商品状态*/
function UpdateIs_new(req,res,msg){ Product.UpdateIs_new(req,res,msg);}

/**获取限时商品详情*/
function getzqProByshopId(req,res,msg){ Product.getzqProByshopId(req,res,msg);}

/**更新限时商品状态*/
function UpdateIs_discount(req,res,msg){ Product.UpdateIs_discount(req,res,msg);}

/**获取积分商品*/
function getPointPro(req,res,msg){ Product.getPointPro(req,res,msg);}

/**获取新人专享商品信息*/
function getNewProInfo(req,res,msg){ Product.getNewProInfo(req,res,msg);}

/**根据barcode获取goods_id*/
function getGoodsIdByBarcode(req,res,msg){ Block.getGoodsIdByBarcode(req,res,msg);}

/**block*/
function getBlockByShopId(req,res,msg){ Block.getBlockByShopId(req,res,msg);}

/**根据shopid获取店铺信息*/
function getShopInfoByShopid(req,res,msg){ Block.getShopInfoByShopid(req,res,msg);}

/**address 获取地址数据*/
function getAddressByUid(req,res,msg){ Block.getAddressByUid(req,res,msg);}

/*更新收货地址*/
function changeAddress(req,res,msg){Block.changeAddress(req,res,msg);}

//*删除收货地址*/
function deleteAddressById(req,res,msg){Block.deleteAddressById(req,res,msg);}

//*获取个人信息*/
function getUserInfoByUid(req,res,msg){Block.getUserInfoByUid(req,res,msg);}

/**获取发现信息*/
function getFaxian(req,res,msg){Block.getFaxian(req,res,msg);}

/**获取发现信息*/
function getRenwu(req,res,msg){Block.getRenwu(req,res,msg);}

//login
function getLoginById(req,res,msg){Login.getLoginById(req,res,msg);}

//注册
function insertUserInfo(req,res,msg){Login.insertUserInfo(req,res,msg);}

/**头像*/
function headPortrait(req,res,msg){Login.headPortrait(req,res,msg);}

/**昵称*/
function nickname(req,res,msg){Login.nickname(req,res,msg);}

/**获取用户积分收支信息*/
function getPointInfoByUserId(req,res,msg){Login.getPointInfoByUserId(req,res,msg);}

//发布评论 添加到数据库
function releaseComment(req,res,msg){Comment.releaseComment(req,res,msg);}

//根据用户的id获取评论
function getCommentById(req,res,msg){Comment.getCommentById(req,res,msg);}

//根据用户的id获取评论
function deleteCommentById(req,res,msg){Comment.deleteCommentById(req,res,msg);}

/**获取用户评论*/
function getTiyanInfo(req,res,msg){Comment.getTiyanInfo(req,res,msg);}

/**点赞*/
function UpdateZan(req,res,msg){Comment.UpdateZan(req,res,msg);}

/**查询点赞数量*/
function getZanByCommentId(req,res,msg){Comment.getZanByCommentId(req,res,msg);}

/**评论*/
function insertComment(req,res,msg){Comment.insertComment(req,res,msg);}

/**获取评论*/
function getComment(req,res,msg){Comment.getComment(req,res,msg);}

/**定位*/
function dingwei(req,res,msg){Dingwei.dingwei(req,res,msg);}